package com.xia.mail;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

public class MainOverTimeCheck {
	public static void sendMails( ) {
		ExecutorService exec = Executors.newSingleThreadExecutor();
		MainOverTimeCheckImplement sendMail = new MainOverTimeCheckImplement();
		Future<String> future = exec.submit(sendMail);
		exec.shutdown();// 调用 shutdown 拒绝传入任务，然后调用 shutdownNow（如有必要）取消所有遗留的任务：
		try {
			String obj = future.get(10000 * 1, TimeUnit.MILLISECONDS);// 100秒没发完算超时
		} catch (TimeoutException e) {
			System.out.println("终结掉");
			System.exit(0);
		} catch (Exception e) {
			System.exit(0);
		}
	}

}
